import 'package:flutter/cupertino.dart';
import 'package:gczn_hd/app/core/base/base_controller.dart';
import 'package:get/get.dart';

class CreateReportController extends BaseController {

  final TextEditingController reportInputController = TextEditingController(); // 报工数控制器
  final TextEditingController badInputController = TextEditingController(); // 不良品控制器
  final TextEditingController remarknputController = TextEditingController(); // 备注控制器


  RxList<String> bcList = [
    "白班",
    "晚班",
  ].obs;
  RxString bcSelect = "白班".obs;

  RxList<Map<String, String>> badList = [
    {"name": "选项1", "checked": "0", "value": "1"},
    {"name": "选项2", "checked": "0", "value": "1"},
    {"name": "选项3", "checked": "0", "value": "1"},
    {"name": "选项4", "checked": "0", "value": "1"},
    {"name": "选项5", "checked": "0", "value": "1"},
  ].obs;

  void toggleChecked(int index) {
    badList[index]['checked'] = badList[index]['checked'] == '1' ? '0' : '1';
    badList.refresh(); // 刷新列表以触发更新
  }

  void setNum(int index, bool type){
    int num = int.parse(badList[index]['value']!);
    if( !type ){
      badList[index]['value'] = num > 0 ? (num - 1).toString() : "0";
    }else{
      badList[index]['value'] = (num + 1).toString();
    }

    badList.refresh(); // 刷新列表以触发更新

  }

}
